import {onMounted, ref} from 'vue'
import TicTacToeBg from '@/assets/images/TicTacToe_bg.png';
import {getAllGames} from "@/api/game.js";

export const useGames = () => {
    const games = ref([
        {
            id: 'TicTacToe',
            name: '井字棋',
            description: '井字棋是最简单的棋牌游戏，老少皆宜，由分别代表O和X的两个游戏者轮流在格子里留下标记（一般来说先手者为X），任意三个标记形成一条直线，则为获胜。',
            image: TicTacToeBg,
            tags: ['策略', '在线对战'],
            playersOnline: '',
            rating: 0
        },

        {
            id: 'SuperTicTacToe',
            name: '超级井字棋',
            description: 'Explore the galaxy and conquer planets',
            image: '/games/space-adventure.jpg',
            tags: ['Strategy', 'Multiplayer'],
            playersOnline: 1243,
            rating: 4.7
        },

        // 其他游戏数据...
    ])

    const selectGame = (game) => {
        console.log('Selected game:', game.name)
        // 导航逻辑
    }
    // onMounted(() => {
    //     getAllGames().then((response)=>{
    //         games.value = response.data
    //     }).catch((error) => {
    //         console.error('获取游戏列表失败:', error)
    //     })
    //     console.log(games.value)
    // })
    return { games, selectGame }
}
